
import { LocalHttpServer } from "../http/LocalHttpServer";
import BaseService from "../../net/service/BaseService";


export default class LocalHttpService extends BaseService {

    private static OK = 4;
    isReady() {
        return true;
    }
    connect() {
        this.onOpen();
    }

    protected server: LocalHttpServer = new LocalHttpServer()

    sendData(message: net.SendMessage) {
        let protoID = message.sendData.protoId;
        let address = this.url;
        let url = `${address}/${protoID}`;
        this.server.send(url, message.data, (err: string, data: string) => {
            if (err) {
                this.onError(err)
            } else {
                this.onData(data)
            }
        })
    }


}
